/// 网络请求数据格式化类
class ResponseData<T> {
  int? code;
  String? msg;
  T? data;

  ResponseData({this.code, this.msg, this.data});

  ResponseData.fromJson(Map<String, dynamic> json,
      T Function(Map<String, dynamic>)? fromJsonFunc) {
    code = json["code"];
    msg = json["msg"];
    data = json["data"] != null && fromJsonFunc != null
        ? fromJsonFunc(json["data"])
        : json["data"];
  }

  // Map<String, dynamic> toJson() {
  //   final Map<String, dynamic> _data = <String, dynamic>{};
  //   _data["code"] = code;
  //   _data["msg"] = msg;
  //   _data["data"] = data;
  //   return _data;
  // }
}

// 网络请求列表数据格式化类
class ResponseListData<T> {
  num? total;
  List<T>? list;

  ResponseListData({this.total, this.list});

  ResponseListData.fromJson(Map<String, dynamic> json,
      T Function(Map<String, dynamic>) fromJsonFunc) {
    total = json["total"];
    list = json["list"] == null
        ? null
        : (json["list"] as List<dynamic>).map((e) => fromJsonFunc(e)).toList();
  }

  // Map<String, dynamic> toJson() {
  //   final Map<String, dynamic> _data = <String, dynamic>{};
  //   _data["total"] = total;
  //   if (list != null) {
  //     _data["list"] = list?.map((e) => e.toJson()).toList();
  //   }
  //   return _data;
  // }
}
